<template>

    <h2>添加会员权益页面</h2>
    <table border="1">
    <tr>
        <td>会员等级权益名称</td>
        <td>
            <input type="text" v-model="info.MR_Name">
        </td>
    </tr>
    <tr>
        <td>会员权益使用</td>
        <td>
            <input type="text" v-model="info.MR_Info">
           
        </td>
    </tr>
    <tr>
        <td>是否自定义权益</td>
        <td>
            <input type="radio" :value="true"  v-model="info.MR_IsCustom">是
            <input type="radio" :value="false" v-model="info.MR_IsCustom">否
        </td>
    </tr>
    <tr>
        <td>使用规则</td>
        <td>
            <textarea v-model="info.MR_Rule"></textarea>
        </td>
    </tr>
    <tr>
        <td>权益类型</td>
        <td>
            <select v-model="info.MR_RuleType">
                <option :value="0">餐饮</option>
                <option :value="1">优惠券</option>
                <option :value="2">延时</option>
            </select>
        </td>
    </tr>
    <tr>
        <td></td>
        <td>
            <input type="button" value="添加" class="btn btn-success" @click="SaveDate">
        </td>
    </tr>
</table>


</template>
<script setup lang="ts">
import axios from 'axios';
import { onMounted,ref } from 'vue';

const info=ref({
    MR_Name:"",
    MR_Info:"",
    MR_IsCustom:false,
    MR_Rule:"",
    MR_RuleType:0



})
console.log(info.value)





const SaveDate=()=>{

    if(info.value.MR_Name==""){
        alert("权益名称不能为空!");
        return;
    }


    axios.post('https://localhost:7153/api/MemberRights/AddMemberRights',info.value)
    // console.log(info.value)
     .then(res=>{
        
        if(res.data==-1){
            alert("权益名称已经存在");
         }
         else if(res.data>0)
        {
             alert("添加成功");
            
         }
         else{
            alert("添加失败");
         }
     })




}

</script>